<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
  <div id="app">
    <button @click="add">生成</button>
    <ul>
      <li v-for="(item,index) in list" :key="item.id">
        <span>{{item.count}}</span><button @click="del(item.id)">删除</button>
      </li>
    </ul>
  </div>

  <script>
    new Vue({
      el: '#app',
      data: {
        list: []
      },
      methods: {
        add() {
          const random = Math.floor(Math.random() * 20)
          console.log(random)
          this.list.unshift({
            id: Date.now(),
            count: random
          })
        },
        del(id) {
          this.list = this.list.filter(item => item.id !== id)
        }
      },
    })
  </script>
</body>

</html>